﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hallenberg.SmartClient.Interfaces;
using System.Web;
using System.Threading;

namespace Hallenberg.SmartClient.MVC.Services
{
    class LocalizationHelper : ILocalization
    {
        const string CurrentCultureName = "CurrentCulture";

        public int GetCurrentLanguageId()
        {
            return (int)HttpContext.Current.Session[CurrentCultureName];
        }

        public void ChangeLanguage(int languageId)
        {
            HttpContext.Current.Session[CurrentCultureName] = languageId;
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(languageId);
        }

        public void SetStoredLanguage()
        {
            ChangeLanguage(this.GetCurrentLanguageId());
        }
    }
}
